from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableMap
from langserve import RemoteRunnable
"""
SDK的方式：
    RemoteRunnable 
"""
openai = RemoteRunnable("http://localhost:8000/chat")
prompt = ChatPromptTemplate.from_messages([
    ("system", "你是一个喜欢写故事的AI助手。请用中文回答用户的问题。"),
    ("user", "写一个故事，主题是{topic}")
])

##
chain = prompt | RunnableMap({
    "chat": openai
})

response = chain.invoke({"topic":"猫"})
print(response)
